<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .color{
            background-color: deepskyblue;
        }
        .rcolor{
            background-color: aquamarine;
        }
        .ac{
            background-color: dimgray;
        }
    </style>
    <script>
        function f() {
            var arr = document.getElementsByTagName('tr');
            for (var i = 1; i <arr.length; i++) {
                if (i%2==0){
                    arr[i].className = "rcolor";
                }
            }
        }
    </script>
</head>
<body onload="f()">
    <table border="1" cellpadding="1" cellspacing="1" width="30%">
        <th class="ac">ID</th>
        <th class="ac">姓名</th>
        <th class="ac">专业</th>
        <tr class="color">
            <td>20180201</td>
            <td>刘备</td>
            <td>全栈</td>
        </tr>
        <tr class="color">
            <td>20180202</td>
            <td>曹操</td>
            <td>java</td>
        </tr>
        <tr class="color">
            <td>20180203</td>
            <td>孙权</td>
            <td>Python</td>
        </tr>
        <tr class="color">
            <td>20180204</td>
            <td>刘表</td>
            <td>大数据</td>
        </tr>
    </table>
</body>
</html>